/** 
 * File: CourseTest.java
 * Project: CMSC 345 Course Registration System, Fall 2010
 * Author: David Chong
 * Date: 12/5/10
 * E-mail: ro62899@umbc.edu
 * This class is used in conjunction with Junit to test the various methods 
 * from the TimeTest.  All of the test passed.
 * 
 * 
 * Class Invariant: None
 */

package registeringSystem;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class LocationTest extends TestCase 
{
	
	/** 
     * Name: testConstructor1 <br><br>
     * Checks that the constructor will be initialized with the valid arguments
     * passed in, there should be no exceptions thrown.
     */
	public void testConstructor1()
	{
		try
		{
		    Location abc = new Location("UMBC main campus", "Engineering", 20);
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testConstructor1()
	
	
	
	/** 
     * Name: testConstructor2 <br><br>
     * Checks that the constructor will throw an exception because a null
     * reference is passed into the first argument.
     */
	public void testConstructor2()
	{
		try
		{
		    Location abc = new Location(null, "Engineering", 20);
		    fail("Should throw an exception because the first argument " +
	    	 "contains a null reference");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testConstructor2()
	
	
	
	/** 
     * Name: testConstructor3 <br><br>
     * Checks that the constructor will throw an exception because a null
     * reference is passed into the second argument.
     */
	public void testConstructor3()
	{
		try
		{
		    Location abc = new Location("UMBC main campus", null, 20);
		    fail("Should throw an exception because the second argument " +
		    	 "contains a null reference");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testConstructor3()
	
	
	
	/** 
     * Name: testConstructor4 <br><br>
     * Checks that the constructor will throw an exception because a negative
     * number is passed into the third argument.
     */
	public void testConstructor4()
	{
		try
		{
		    Location abc = new Location("UMBC main campus", "Engineering", -1);
		    fail("Should throw an exception because a negative number was " +
		    	 "passed in!\n");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testConstructor4()
	
	
	
	/** 
     * Name: testConstructor5 <br><br>
     * Checks that the copy constructor will throw an exception because a null
     * reference is passed in.
     */
	public void testConstructor5()
	{
		try
		{
		    Location abc = null;
		    Location def = new Location(abc);
		    fail("It should throw an exception because the argument for the " +
		    	 "the copy constructor was a null reference");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testConstructor5()
	
	
	
	/** 
     * Name: testConstructor6 <br><br>
     * Checks that the copy constructor works.  All of the assertTrue in the
     * method should pass.
     */
	public void testConstructor6()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    Location def = new Location(abc);
		    
		    assertTrue(def.getCampusSite().equals("A"));
		    assertTrue(def.getBuildingName().equals("B"));
		    assertTrue(def.getRoomNumber() == 20);
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testConstructor6()
	
	
	
	/** 
     * Name: testSetCampusSite <br><br>
     * Checks that the mutator will throw a exception because an invalid is
     * used.
     */
	public void testSetCampusSite()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    abc.setCampusSite(null);
		    fail("Should throw an exception because a null reference was " +
		    	 "passed in!\n");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testSetCampusSite()
	
	
	
	/** 
     * Name: testSetBuildingName <br><br>
     * Checks that the mutator will throw a exception because an invalid is
     * used.
     */
	public void testSetBuildingName()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    abc.setBuildingName(null);
		    fail("Should throw an exception because a null reference was " +
		    	 "passed in!\n");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testSetBuildingName()
	
	
	
	/** 
     * Name: testSetRoomNumber <br><br>
     * Checks that the mutator will throw a exception because an invalid is
     * used.
     */
	public void testSetRoomNumber()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    abc.setRoomNumber(-10);
		    fail("Should throw an exception because a negative number was " +
		    	 "passed in!\n");
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testSetRoomNumber()
	
	
	
	/** 
     * Name: testEquals1 <br><br>
     * Checks that the equals method when the passed in argument is a null
     * reference.
     */
	public void testEquals1()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    Location def = null;
		    assertFalse(abc.equals(def));
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testEquals1()
	
	
	
	/** 
     * Name: testEquals2 <br><br>
     * Checks that the equals method.
     */
	public void testEquals2()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    Location def = new Location("B", "B", 20);
		    assertFalse(abc.equals(def));
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testEquals2()
	
	
	
	/** 
     * Name: testEquals3 <br><br>
     * Checks that the equals method.
     */
	public void testEquals3()
	{
		try
		{
		    Location abc = new Location("A", "B", 20);
		    Location def = new Location("A", "B", 20);
		    assertTrue(abc.equals(def));
		} // end of try block
		
		catch(Exception e)
		{
			; // do nothing
		} // end of catch block
	} // end of testEquals1()
	
	
	
	/** 
     * Name: suite <br><br>
     * Runs all of the test cases specified in the class.  Returns a TestSuite
     * object to test this class with JUnit.
     */
    public static Test suite()
    {
    	return new TestSuite(LocationTest.class);
    } // end of suite()
} // end of LocationTest class